What is this `adb` utility I keep getting advice to use?


Question

In a bunch of questions on this site I see answers telling us to execute adb shell or adb logcat and so on.



Now, I'm not an entirely clueless user, so I downloaded and installed Termux and have a shell prompt when I can type in commands, but - where does this adb thing come from? Do I download it as an app? It doesn't seem to be installed by default (On a Redmi 3S, Android 6.0.1).



Also, it seems like it's some kind of permission elevator. Is it like su? If not, how is it different?


Answer

About adb



To put it shortly, adb (Android Debug Bridge) is a utility made to be installed on a computer, in order to let it gain a shell on a phone that's either connected via USB cable, or on the same Wi-Fi network.



On certain devices running Android Lollipop (5.1.1) and possibly lower versions of the OS, it was possible to trick a device into connecting to itself, since the adb client came bundled in the phone as well. This is not possible any more because, from Android Marshmallow (6.0) onwards, Google removed the adb binary from the phones to reduce the usable attack surface.



It is possible, though, to manually reintroduce the adb client on a phone, without needing to compile the binary yourself. Refer to the adb tag wiki for more info about this topic, as well as about installation on a computer and general troubleshooting.






Where to get it



Some time ago, in order to obtain adb and another utility, called fastboot, one had to download the full Android SDK from Google, if they wanted an official package. Nowadays, a small, official bundle has become available, as XDA says. It includes binaries for the most common operating systems.






How it works



The adb client, installed on your computer, makes a connection to a plugged or otherwise detectable phone, by means of an internal server. Then, the user will be able to send a variety of commands to the phone itself, which will be listened to by adbd, a daemon residing on the phone.



When using adb, you impersonate the user called shell (UID 2000). This user is special, in that they can grant app permissions and access more information than a simple user. This fact, though, does not mean that adb is the same as su, as the latter lets you impersonate any user.



More info about adb and its workings may be obtained by looking at the official documentation.






Issuing commands from a phone



The majority of commands that can be issued via adb tend to be utilities that come preinstalled in a phone.



In order to access them, you need to install a terminal emulator app on your phone (note that Termux is special, in that it specifies its own PATH, thereby ignoring system binaries). This will, for example, let you issue commands such as logcat directly on your mobile device. Remember to omit the adb prefix, though.



It is worth mentioning that, should you lack root permissions, the range of commands you'll be able to execute and the info you'll be able to access will be significantly less than if using adb, because the UID that invokes them will be the app itself, and apps have less permissions than UID 2000.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes